extensions: protect another conversion against /0.0
authorØyvind Kolås <pippin@gimp.org>
Fri, 10 Nov 2017 09:44:21 +0000 (10:44 +0100)
committerØyvind Kolås <pippin@gimp.org>
Fri, 10 Nov 2017 09:44:21 +0000 (10:44 +0100)
extensions/gggl.c

index d101bef37161cee7d554fc7b87b5ab79b5cde810..cf83988092a3b669645df4b570b83140d0c03940 100644 (file)
@@ -560,10 +560,16 @@ conv_rgbA16_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst
     {
       float alpha = (((unsigned short *) src)[3]) / 65535.0;
       int   c;
+      float recip_alpha;
+
+      if (alpha == 0.0f)
+        recip_alpha = 10000.0;
+      else
+        recip_alpha = 1.0/alpha;
 
       for (c = 0; c < 3; c++)
         {
-          (*(float *) dst) = (*(unsigned short *) src / 65535.0) alpha;
+          (*(float *) dst) = (*(unsigned short *) src / 65535.0) * recip_alpha;
           dst             += 4;
           src             += 2;
         }